﻿// <copyright file="EnumerableExtensionsTests.cs" company="Fluent.NET">
// Microsoft Public License (Ms-PL)
// </copyright>
// <author>Chris Eargle</author>
// <email>kodefuguru@live.com</email>
// <date>2010-01-21</date>
// <summary>EnumerableExtensions class tests</summary>
namespace Fluent.Tests
{
    using System.Collections.Generic;
    using System.Linq;
    using Fluent;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// Contains tests for Sequence
    /// </summary>
    [TestClass]
    public class EnumerableExtensionsTests
    {
        /// <summary>
        /// Tests the With method.
        /// </summary>
        [TestMethod]
        public void With()
        {
            var strings = new[] { "This", "is", "a" } .AsEnumerable();
            strings = strings.With("test");
            Assert.IsTrue(strings.Contains("test"));
        }

        /// <summary>
        /// Tests that the With method does not produce side effects.
        /// </summary>
        [TestMethod]
        public void WithShouldNotHaveSideEffects()
        {
            var strings = new List<string> { "This", "is", "a" };
            var strings2 = strings.With("test");
            Assert.IsTrue(strings2.Contains("test"));
            Assert.IsFalse(strings.Contains("test"));
        }
    }
}
